import 'package:flutter/material.dart';

class Paper extends StatelessWidget {
  const Paper({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: CustomPaint(
        painter: PaperPainter(),
      ),
    );
  }
}

class PaperPainter extends CustomPainter {
  final Paint mPaint = Paint();
  final Path mPath = Path();

  @override
  void paint(Canvas canvas, Size size) {
    // 绘制圆
    canvas.drawCircle(const Offset(100, 100), 10, mPaint);

    mPaint
      ..color = Colors.blue
      ..strokeWidth = 4
      ..style = PaintingStyle.stroke;
    canvas.drawLine(const Offset(0, 0), const Offset(100, 100), mPaint);

    mPath.moveTo(200, 200);
    mPath.lineTo(300, 100);
    canvas.drawPath(mPath, mPaint..color = Colors.yellow);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
